/*     */ package com.zimbra.cs.client.soap;
/*     */ 
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.soap.DomUtil;
/*     */ import com.zimbra.common.soap.MailConstants;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Iterator;
/*     */ import org.dom4j.DocumentHelper;
/*     */ import org.dom4j.Element;
/*     */ import org.dom4j.QName;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class LmcSearchRequest
/*     */   extends LmcSoapRequest
/*     */ {
/*     */   private String mLimit;
/*     */   private String mOffset;
/*     */   private String mTypes;
/*     */   private String mSortBy;
/*     */   private String mQuery;
/*     */   
/*     */   public void setLimit(String l)
/*     */   {
/*  44 */     this.mLimit = l;
/*     */   }
/*     */   
/*     */   public void setOffset(String o) {
/*  48 */     this.mOffset = o;
/*     */   }
/*     */   
/*     */   public void setTypes(String t) {
/*  52 */     this.mTypes = t;
/*     */   }
/*     */   
/*     */   public void setSortBy(String s) {
/*  56 */     this.mSortBy = s;
/*     */   }
/*     */   
/*     */   public void setQuery(String q) {
/*  60 */     this.mQuery = q;
/*     */   }
/*     */   
/*     */   public String getLimit() {
/*  64 */     return this.mLimit;
/*     */   }
/*     */   
/*     */   public String getOffset() {
/*  68 */     return this.mOffset;
/*     */   }
/*     */   
/*     */   public String getTypes() {
/*  72 */     return this.mTypes;
/*     */   }
/*     */   
/*     */   public String getSortBy() {
/*  76 */     return this.mSortBy;
/*     */   }
/*     */   
/*     */   public String getQuery() {
/*  80 */     return this.mQuery;
/*     */   }
/*     */   
/*     */   protected Element createQuery(QName elemName) {
/*  84 */     Element request = DocumentHelper.createElement(elemName);
/*     */     
/*     */ 
/*  87 */     addAttrNotNull(request, "limit", this.mLimit);
/*  88 */     addAttrNotNull(request, "offset", this.mOffset);
/*  89 */     addAttrNotNull(request, "types", this.mTypes);
/*  90 */     addAttrNotNull(request, "sortBy", this.mSortBy);
/*     */     
/*     */ 
/*  93 */     DomUtil.add(request, "query", this.mQuery);
/*     */     
/*  95 */     return request;
/*     */   }
/*     */   
/*     */   protected Element getRequestXML() {
/*  99 */     return createQuery(MailConstants.SEARCH_REQUEST);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   protected void parseResponse(LmcSearchResponse response, Element responseXML)
/*     */     throws ServiceException, LmcSoapClientException
/*     */   {
/* 108 */     response.setOffset(DomUtil.getAttr(responseXML, "offset"));
/* 109 */     response.setMore(DomUtil.getAttr(responseXML, "more"));
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 115 */     ArrayList mailItems = new ArrayList();
/* 116 */     for (Iterator it = responseXML.elementIterator(); it.hasNext();) {
/* 117 */       Element e = (Element)it.next();
/*     */       
/*     */ 
/* 120 */       String elementType = e.getQName().getName();
/*     */       Object o;
/* 122 */       if (elementType.equals("c")) {
/* 123 */         o = parseConversation(e); } else { Object o;
/* 124 */         if (elementType.equals("m")) {
/* 125 */           o = parseMessage(e); } else { Object o;
/* 126 */           if (elementType.equals("mp")) {
/* 127 */             o = parseMimePart(e); } else { Object o;
/* 128 */             if (elementType.equals("cn")) {
/* 129 */               o = parseContact(e); } else { Object o;
/* 130 */               if (elementType.equals("note")) {
/* 131 */                 o = parseNote(e); } else { Object o;
/* 132 */                 if (elementType.equals("doc")) {
/* 133 */                   o = parseDocument(e); } else { Object o;
/* 134 */                   if (elementType.equals("w")) {
/* 135 */                     o = parseWiki(e);
/*     */                   }
/*     */                   else
/* 138 */                     throw new LmcSoapClientException("Unexpected element type " + elementType);
/*     */                 }
/*     */               } } } } }
/*     */       Object o;
/* 142 */       mailItems.add(o);
/*     */     }
/*     */     
/* 145 */     response.setResults(mailItems);
/*     */   }
/*     */   
/*     */   protected LmcSoapResponse parseResponseXML(Element responseXML)
/*     */     throws ServiceException, LmcSoapClientException
/*     */   {
/* 151 */     LmcSearchResponse response = new LmcSearchResponse();
/* 152 */     parseResponse(response, responseXML);
/* 153 */     return response;
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/client/soap/LmcSearchRequest.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */